/**
 * author: Maxim Dybarskiy
 * date:   Jun 22, 2011
 * time:   4:48:57 PM
 */
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import d.max.wallpaper.Activity;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class TreeAdapter extends BaseAdapter {
    
    private Activity activity;
    
    private File[] files = new File[0];
    private List<File> expanded = new ArrayList<File>();

    public TreeAdapter(Activity activity) {
        this.activity = activity;
    }

    public void setFiles(File[] files) {
        this.files = files;
    }

    public File[] getFiles() {
        return files;
    }

    public void addExmapded(File file) {
        expanded.add(file);
    }
    
    public void removeExpanded(File file) {
        expanded.remove(file);
    }
    
    @Override
    public int getCount() {
        return files.length;
    }

    @Override
    public Object getItem(int i) {
        return files[i];
    }

    @Override
    public long getItemId(int i) {
        return files[i].hashCode();
    }

    @Override
    public View getView(int i, View view, ViewGroup vg) {
        return new FileView(activity, files[i]);
    }
}
